package dp;

import java.util.Arrays;

/**
 * @author : Rookie
 * @description : 不同路径
 * @date : 2024/1/12
 */
public class DifferentPathI {

    public static void main(String[] args) {
        int m=3,n=7;
        int path = getPathCount(m, n);
        System.out.println(path);
    }

    private static int getPathCount(int m,int n) {
        // dp表示从起点到dp[i][j]的路径数量
        int[][] dp = new int[m][n];
        for (int i = 0; i < m; i++) {
            dp[i][0] = 1;
        }
        for (int i = 0; i < n; i++) {
            dp[0][i] = 1;
        }
        Common.print2dArr(dp);
        for (int i = 1; i < m; i++) {
            for (int j = 1; j < n; j++) {
                // 两种走法 要么从左边 要么从上面
                dp[i][j] = dp[i][j-1]+dp[i-1][j];
            }
        }
        System.out.println("=========");
        Common.print2dArr(dp);
        return dp[m-1][n-1];

    }
}
